package com.ctg.mainframe.sdk.utils;

import com.ctg.itrdc.sysmgr.permission.core.CtgUser;
import com.ctg.itrdc.sysmgr.permission.core.utils.WebUtils;
import com.ctg.mainframe.sdk.dto.SysMgrInfoDTO;

public class LoginSessionHelper {
	
	/**
	 * 从Session获取CtgUser
	 */
	public static CtgUser getSessionInfo() {
		try {
			return null == WebUtils.getCtgUser() ? null : WebUtils.getCtgUser();
		} catch (Exception e) {
			return null;
		}
	}
	
	public static Long getCacheKeyFromSession() {
		try {
			CtgUser ctgUser = WebUtils.getCtgUser();
			return WebUtils.getCtgUser().getSysUserId();
		} catch (Exception e) {
			return null;
		}
	}
	
	/**
	 * 获取缓存信息
	 * @return
	 */
	public static SysMgrInfoDTO getSysMgrInfoCache() {
		try {
			return CacheHelper.getSysMgrInfoCache(WebUtils.getCtgUser().getSysUserId()+"");
		} catch (Exception e) {
			return null;
		}
	}
	
	public static Long getSysUserId() {
		if (null == getSysMgrInfoCache()) return null;
		Long sysUserId = getSysMgrInfoCache().getSysUserId();
		return null == sysUserId ? -1L : sysUserId;
	}
	
	public static String getSysUserCode() {
		if (null == getSysMgrInfoCache()) return null;
		String sysUserCode = getSysMgrInfoCache().getSysUserCode();
		return null == sysUserCode ? null : getSysMgrInfoCache().getSysUserCode();
	}
	
	public static Long getStaffId() {
		if (null == getSysMgrInfoCache()) return null;
		Long staffId = getSysMgrInfoCache().getStaffId();
		return null == staffId ? -1L : staffId;
	}
	
	public static String getSysCode() {
		if (null == getSysMgrInfoCache()) return null;
		String sysCode = getSysMgrInfoCache().getSysCode();
		return null == sysCode ? null : sysCode;
	}
	
	public static Long getSysPostId() {
		if (null == getSysMgrInfoCache()) return null;
		Long sysPostId = getSysMgrInfoCache().getSysPostId();
		return null == sysPostId ? -1L : sysPostId;
	}
	
	public static String getSysPostName() {
		if (null == getSysMgrInfoCache()) return null;
		String sysPostName = getSysMgrInfoCache().getSysPostName();
		return null == sysPostName ? null : sysPostName;
	}
	
	public static Long getOrgId() {
		if (null == getSysMgrInfoCache()) return null;
		Long orgId = getSysMgrInfoCache().getOrgId();
		return null == orgId ? -1L : orgId;
	}
	
	public static String getOrgName() {
		if (null == getSysMgrInfoCache()) return null;
		String orgName = getSysMgrInfoCache().getOrgName();
		return null == orgName ? null : orgName;
	}
	
	public static Long getCommonRegionId() {
		if (null == getSysMgrInfoCache()) return null;
		Long commonRegionId = getSysMgrInfoCache().getCommonRegionId();
		return null == commonRegionId ? -1L : commonRegionId;
	}
	
	public static String getCommonRegionName() {
		if (null == getSysMgrInfoCache()) return null;
		String commonRegionName = getSysMgrInfoCache().getCommonRegionName();
		return null == commonRegionName ? null : commonRegionName;
	}
	
	public static Long getProvCommonRegionId() {
		if (null == getSysMgrInfoCache()) return null;
		Long provCommonRegionId = getSysMgrInfoCache().getProvCommonRegionId();
		return null == provCommonRegionId ? -1L : provCommonRegionId;
	}
	
	public static String getProvCommonRegionName() {
		if (null == getSysMgrInfoCache()) return null;
		String provCommonRegionName = getSysMgrInfoCache().getProvCommonRegionName();
		return null == provCommonRegionName ? null : provCommonRegionName;
	}
	
	public static Long getLanId() {
		if (null == getSysMgrInfoCache()) return null;
		Long lanId = getSysMgrInfoCache().getLanId();
		return null == lanId ? -1L : lanId;
	}
	
	public static String getLanName() {
		if (null == getSysMgrInfoCache()) return null;
		String lanName = getSysMgrInfoCache().getLanName();
		return null == lanName ? null : lanName;
	}
	
	public static Long getProvinceId() {
		if (null == getSysMgrInfoCache()) return null;
		Long provinceId = getSysMgrInfoCache().getProvinceId();
		return null == provinceId ? -1L : provinceId;
	}
	
	public static String getProvinceName() {
		if (null == getSysMgrInfoCache()) return null;
		String provinceName = getSysMgrInfoCache().getProvinceName();
		return null == provinceName ? null : provinceName;
	}
	
	public static Long getCityId() {
		if (null == getSysMgrInfoCache()) return null;
		Long cityId = getSysMgrInfoCache().getCityId();
		return null == cityId ? null : cityId;
	}
	
	public static String getCityName() {
		if (null == getSysMgrInfoCache()) return null;
		String cityName = getSysMgrInfoCache().getCityName();
		return null == cityName ? null : cityName;
	}
	
	public static Long getCountyId() {
		if (null == getSysMgrInfoCache()) return null;
		Long countyId = getSysMgrInfoCache().getCountyId();
		return null == countyId ? -1L : countyId;
	}
	
	public static String getCountyName() {
		if (null == getSysMgrInfoCache()) return null;
		String countyName = getSysMgrInfoCache().getCountyName();
		return null == countyName ? null : countyName;
	}
}
